
package org.example.caiwumanage.service.impl;



import org.example.caiwumanage.entity.Budgetrecords;
import org.example.caiwumanage.entity.Query;
import org.example.caiwumanage.mapper.TransactionMapper;
import org.example.caiwumanage.properties.BaseContext;
import org.example.caiwumanage.result.Result;
import org.example.caiwumanage.service.TransactionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class TransactionServiceImpl implements TransactionService {
    @Autowired
    private TransactionMapper transactionMapper;

    @Override
    public void create(Budgetrecords budgetrecords) {
        long id= BaseContext.getCurrentId();//用线程获取id
        budgetrecords.setUserId(id);
        transactionMapper.create(budgetrecords);
    }

    @Override
    public void delete(Integer budgetId) {
        long id= BaseContext.getCurrentId();//用线程获取id
        transactionMapper.delete(budgetId,id);
    }

    @Override
    public void update(Budgetrecords budgetrecords) {
        long id= BaseContext.getCurrentId();//用线程获取id
        budgetrecords.setUserId(id);
        transactionMapper.update(budgetrecords);
    }


    @Override
    public List<Budgetrecords> select(Long id){
        return transactionMapper.select(id);
    }

    @Override
    public List<Budgetrecords> query(Query query) {
        Long id=BaseContext.getCurrentId();
        query.setUserId(id);
        return transactionMapper.query(query);
    }

}